package com.v512.webproject1;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class GetServerInfoServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out
				.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("  <BODY>");
		printContent(request, out);
		out.println("  </BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}

	public void printContent(HttpServletRequest request, PrintWriter out) {
		out.println("server name:" + request.getServerName() + "<br>");
		out.println("server ip:" + request.getRemoteAddr() + "<br>");
		out.println("server port:" + request.getServerPort() + "<br>");
		out.println("server protocol:" + request.getProtocol() + "<br>");
		out.println("server contextpath:" + request.getContextPath() + "<br>");
		out.println("server scheme:" + request.getScheme() + "<br>");
		out.println("server method:" + request.getMethod() + "<br>");
		out.println("server uri:" + request.getRequestURI() + "<br>");
		out.println("server servletpath:" + request.getServletPath() + "<br>");
	}

}
